export let playlist_tracks = {
  namespaced: true,
  state: {
    playlist_tracks_data: {}
  },
  actions: {
    // 调用此接口 , 可以添加歌曲到歌单或者从歌单删除某首歌曲 ( 需要登录 )
    getPlaylistTracksData(store, data = {}) {
      let url = "/playlist/tracks?op=" + data.op + "&pid=" + data.pid + "&tracks=" + data.tracks + "&timestamp=" + new Date().getTime();
      return new Promise((resolve, reject) => {
        axios.get(url).then(({
          data
        }) => {
          store.commit('setPlaylistTracksData', data);
          resolve(data);
        }).catch((error) => {
          if (error.response) {
            // 请求已发出，但服务器响应的状态码不在 2xx 范围内
            reject(error.response.data)
          }
        });
      });
    }
  },
  mutations: {
    setPlaylistTracksData(state, data) {
      state.playlist_tracks_data = data;
    }
  }
}
